home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Almathera Ten Pack 3: CDPD 3
/
Almathera Ten on Ten - Disc 3: CDPD3.iso
/
ab20
/
ab20_archive
/
utilities
/
editors
/
emacs-18.58.lha
/
emacs
/
lisp
/
amiga-menu.el
< prev
next >
Wrap
Lisp/Scheme
|
1992-01-02
|
2KB
|
53 lines
;(provide 'amiga-menu)
(defvar amiga-menus-description nil
"Variable containing the menus setup for Emacs")
(defun amiga-menus-set (menus)
"Setup menus for emacs (parameter as for amiga-menus)"
(define-key mouse-map amiga-button-right-up 'amiga-menus-dispatch)
(setq amiga-menus-description menus)
(amiga-menus menus))
(defun amiga-menus-dispatch (selection)
(let ((menu (car selection))
(item (cadr selection)))
(eval (cadr (nth item (cadr (nth menu amiga-menus-description)))))))
(defun make-explicit-string (str)
(if (and (>= (length str) 2) (= (elt str 0) 27) (< (elt str 1) 128))
(key-description (concat (char-to-string (+ 128 (elt str 1)))
(substring str 2)))
(key-description str)))
(defun make-command-name (command str width)
(let ((keys (where-is-internal command nil t))
(string (if str str (symbol-name command))))
(if keys
(format (format "%%-%ds%%s" width) string (make-explicit-string keys))
string)))
(defun menu-items (commands)
(let* ((width 0)
(names (mapcar
(function (lambda (cmd)
(if cmd
(let* ((name (if (symbolp cmd)
(symbol-name cmd)
(car cmd)))
(len (length name)))
(if (> len width) (setq width len))
name))))
commands)))
(mapcar
(function (lambda (cmd)
(let ((name (car names)))
(setq names (cdr names))
(if cmd
(let ((command (if (symbolp cmd) cmd (cadr cmd))))
(list (make-command-name command name (+ width 2))
(list 'call-interactively (list 'quote command))
(caddr cmd)))))))
commands)))